package cn.xingzhe.monster.user.domain.exception;

/**
 * 用户已存在异常
 *
 * @author System
 * @version 1.0.0
 * @since 2024-01-01
 */
public class UserAlreadyExistsException extends UserException {

    private static final String ERROR_CODE = "A0111";
    private static final String DEFAULT_MESSAGE = "用户已存在";

    /**
     * 构造函数
     */
    public UserAlreadyExistsException() {
        super(ERROR_CODE, DEFAULT_MESSAGE);
    }

    /**
     * 构造函数
     *
     * @param message 错误消息
     */
    public UserAlreadyExistsException(String message) {
        super(ERROR_CODE, message);
    }

    /**
     * 创建用户名已存在异常
     *
     * @param username 用户名
     * @return UserAlreadyExistsException
     */
    public static UserAlreadyExistsException usernameExists(String username) {
        return new UserAlreadyExistsException("用户名已存在: " + username);
    }

    /**
     * 创建邮箱已存在异常
     *
     * @param email 邮箱
     * @return UserAlreadyExistsException
     */
    public static UserAlreadyExistsException emailExists(String email) {
        return new UserAlreadyExistsException("邮箱已存在: " + email);
    }

    /**
     * 创建手机号已存在异常
     *
     * @param phone 手机号
     * @return UserAlreadyExistsException
     */
    public static UserAlreadyExistsException phoneExists(String phone) {
        return new UserAlreadyExistsException("手机号已存在: " + phone);
    }
}

